package com.zhuiyun.project.api.coachmanagement.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.coachmanagement.model.*;
import com.zhuiyun.project.api.coachmanagement.service.CoachManagementService;
import com.zhuiyun.project.api.monitor.domain.server.Sys;
import com.zhuiyun.project.common.controller.BaseController;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AppCoachController
 * @Description TODO 教练端app个人信息控制层
 * @Author 杨友朋
 * @Date 2023/11/29 10:32
 **/
@RestController
@RequestMapping("/AppCoach")
@Api(tags ="教练端app个人信息控制层")
@Slf4j
public class AppCoachController extends BaseController {
    @Autowired
    private CoachManagementService coachManagementService;

    /**
     * @Author 杨友朋
     * @Description 根据id查询教练
     * @Date 2023/11/28 9:06
     * @Return CommonResult
     * @param id
     */
    @GetMapping("/getCoachById")
    @ApiOperation(value = "根据id查询教练")
    @OptLog(modular = "教练管理",type = CommonConstants.SELECT,describe = "根据id查询教练")
    public CommonResult getCoachById(int id){
        return coachManagementService.getCoachById(id);
    }

    /**
     * @Author 杨友朋
     * @Description 根据教练邀请码查询学员
     * @Date 2023/11/28 9:06
     * @Return CommonResult
     * @param coachCode
     */
    @GetMapping("/getStudentByTeacherId")
    @ApiOperation(value = "根据教练邀请码查询学员")
    @OptLog(modular = "教练管理",type = CommonConstants.SELECT,describe = "根据教练邀请码查询学员")
    public CommonResult getStudentByTeacherId(String coachCode){
        return coachManagementService.getStudentByTeacherId(coachCode);
    }
    /**
     * @Author wuwan
     * @Description 根据学员查询剩余课程
     * @Date 2023/11/28 9:06
     * @Return CommonResult
     * @param coachCode
     */
    @GetMapping("/getStudentByTeacherIdUser")
    @ApiOperation(value = "根据教练邀请码查询学员")
    @OptLog(modular = "教练管理",type = CommonConstants.SELECT,describe = "根据教练邀请码查询学员")
    public CommonResult getStudentByTeacherIdUser(Integer userid,String coachCode){
        return coachManagementService.getStudentByTeacherIdUser(userid,coachCode);
    }

    /**
     * @Author 杨友朋
     * @Description 加密
     * @Date 2023/11/28 9:06
     * @Return Boolean
     * @param word,myWord
     */
    @GetMapping("/encryption")
    @ApiOperation(value = "加密")
    public CommonResult encryption(String word,String myWord){
        Boolean encryption = coachManagementService.encryption(word, myWord);
        if(encryption==true){
            return CommonResult.ok("验证成功");
        }else {
            return CommonResult.error(1433,"验证失败");
        }
    }

    /**
     * @Author 杨友朋
     * @Description 修改密码
     * @Date 2023/11/29 9:32
     * @Return CommonResult
     * @param coachUpPasswordModel
     */
    @PostMapping("/upPassword")
    @ApiOperation(value = "修改密码")
    @OptLog(modular = "教练管理",type = CommonConstants.UPDATE,describe = "修改密码")
    public CommonResult upPassword(@RequestBody CoachUpPasswordModel coachUpPasswordModel) throws CommonException {
        return coachManagementService.upPassword(coachUpPasswordModel);
    }

    /**
     * @Author 杨友朋
     * @Description 修改姓名
     * @Date 2023/11/29 9:32
     * @Return CommonResult
     * @param coachUpNameModel
     */
    @PostMapping("/upName")
    @ApiOperation(value = "修改姓名")
    @OptLog(modular = "教练管理",type = CommonConstants.UPDATE,describe = "修改姓名")
    public CommonResult upName(@RequestBody CoachUpNameModel coachUpNameModel) throws CommonException {
        return coachManagementService.upName(coachUpNameModel);
    }

    /**
     * @Author 杨友朋
     * @Description 修改性别
     * @Date 2023/11/29 9:32
     * @Return CommonResult
     * @param coachUpSexModel
     */
    @PostMapping("/upSex")
    @ApiOperation(value = "修改密码")
    @OptLog(modular = "教练管理",type = CommonConstants.UPDATE,describe = "修改密码")
    public CommonResult upSex(@RequestBody CoachUpSexModel coachUpSexModel) throws CommonException {
        return coachManagementService.upSex(coachUpSexModel);
    }
    /**
     *
     * @Author shy  TODO  修改学员备注
     * @Date 2024/2/29 19:24
      * @param coachUpNotesModel
     * @return CommonResult
     */
    @PostMapping("upNotes")
    @ApiOperation(value = "修改学员备注")
    @OptLog(modular = "教练管理",type = CommonConstants.UPDATE,describe = "修改学员备注")
    public CommonResult upNotes(@RequestBody CoachUpNotesModel coachUpNotesModel){
        return coachManagementService.coachUpNotes(coachUpNotesModel);
    }

    @GetMapping("getCoachByVenueUniqueIdentifier")
    @ApiOperation(value = "根据门店标识符查询教练")
    @OptLog(modular = "教练管理",type = CommonConstants.SELECT,describe = "根据门店标识符查询教练")
    public CommonResult getCoachByVenueUniqueIdentifier(String VenueUniqueIdentifier,String id){
        return coachManagementService.getCoachByVenueUniqueIdentifier(VenueUniqueIdentifier,id);
    }

    @PostMapping("/studentHandover")
    @ApiOperation(value = "学员转交")
    @OptLog(modular = "教练管理",type = CommonConstants.UPDATE,describe = "学员转交")
    public CommonResult studentHandover(@RequestBody CoachHandoverModel coachHandoverModel) throws CommonException {
        System.out.println(coachHandoverModel);
        return coachManagementService.studentHandover(coachHandoverModel);
    }
}
